var pageParam = {};

$(function() {
	$('#vue_vm_list').hide();
});

function beHospitalFees_findByDay() {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list').hide();
	var year = $('#year').val();
	var month = $('#month').val();
	var day = $('#day').val();
	var searchVal = $('#searchVal').val();
	
	if(isEmpty(year)) {
		alert('请输入年');
		return;
	}
	if(isEmpty(month)) {
		alert('请选择月');
		return;
	}
	if(isEmpty(day)) {
		alert('请选择日');
		return;
	}
	if(isEmpty(searchVal)) {
		alert('请输入姓名或身份证');
		return;
	}
	
	find_basic_by_json(path+'/beHospitalFees/findByDay', {day: getStandardDay(year, month, day), searchVal: searchVal}, function(response) {	
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			},
			methods: {
				getPrePay:function(todo) {
					return todo.totalPay - todo.pledgePay;
				},
				printPledge:function(todo) {
					return printPledge(todo);
				},
				printPrePay:function(todo) {
					return printPrePay(todo);
				}
			}
		});
		
		$('#vue_vm_list').show();
	});
}

function printPledge(data) {
	data.elderName = data.elderForm.name;
	data.beNumber = data.elderBeHospitalForm.beNumber;
	data.payDate = data.createTime;
	data.staffName = getLoginedUser()? getLoginedUser().staffName: '';
	data.payType = '押金';
	data.pay = data.pledgePay;
	pageParam = data;
	pageParam.paperType = 2;
	pageParam.relationId = data.elderBeHospitalForm.beHospitalId + '-beHospitalPlede';
    pageParam.beHospitalId = data.elderBeHospitalForm.beHospitalId;
	window.open('0_print_jf.html?pageParam='+encodeURIComponent(JSON.stringify(pageParam)));
}

function printPrePay(data) {
	data.elderName = data.elderForm.name;
	data.beNumber = data.elderBeHospitalForm.beNumber;
	data.payDate = data.createTime;
	data.staffName = getLoginedUser()? getLoginedUser().staffName: '';
	data.payType = '预交款';
	data.pay = data.totalPay - data.pledgePay;
	pageParam = data;
	pageParam.paperType = 2;
	pageParam.relationId = data.elderBeHospitalForm.beHospitalId + '-prePay';
    pageParam.beHospitalId = data.elderBeHospitalForm.beHospitalId;
	window.open('0_print_jf.html?pageParam='+encodeURIComponent(JSON.stringify(pageParam)));
}